var e, t, a, r, n, i, s, d, c = require("../../../@babel/runtime/helpers/interopRequireDefault"), o = require("../../../@babel/runtime/helpers/defineProperty"), u = c(require("../../../@babel/runtime/regenerator")), l = require("../../../@babel/runtime/helpers/asyncToGenerator"), p = c(require("../../../utils/api")), h = getApp();

Page({
    data: {
        statusBarHeight: h.globalData.statusBarHeight,
        resourceUrl: h.globalData.resourceUrl,
        countdown: "",
        timeLimit: 0,
        interval: null,
        indexNum: 0,
        endNum: 0,
        questionId: "",
        questionType: 0,
        questionTypeName: "",
        imageArray: [],
        options: [],
        answer: "",
        analysis: "",
        answerState: 0,
        disable: !1,
        correctIndex: -1,
        errorIndex: -1,
        answerProgress: 1,
        correct: 0,
        dialogShow: !1,
        show: !1,
        cardActive: "",
        finished: !1,
        started: !1,
        list: {
            resurrection: {
                cardname: "复活卡",
                cardId: 0,
                cardNum: 0,
                image: "/answer/images/resurrection-card.png"
            },
            skip: {
                cardname: "跳过卡",
                cardId: 1,
                cardNum: 0,
                image: "/answer/images/skip-card.png"
            },
            delay: {
                cardname: "延时卡",
                cardId: 2,
                cardNum: 0,
                image: "/answer/images/delay-card.png"
            },
            debug: {
                cardname: "去错卡",
                cardId: 3,
                cardNum: 0,
                image: "/answer/images/debug-card.png"
            },
            double: {
                cardname: "翻倍卡",
                cardId: 4,
                cardNum: 0,
                image: "/answer/images/double-card.png"
            }
        },
        activityId: ""
    },
    debounce: function(e, t) {
        var a = arguments.length > 2 && void 0 !== arguments[2] && arguments[2], r = null;
        return function() {
            var n = arguments, i = this;
            r && clearTimeout(r), a ? (r || e.apply(this, arguments), r = setTimeout(function() {
                r = null;
            }, t)) : r = setTimeout(function() {
                e.apply(i, n);
            }, t);
        };
    },
    changeCountDown: function(e) {
        var t = this, a = parseInt(e / 60), r = parseInt(e % 60);
        return this.setData({
            countdown: (a < 10 ? "0" + a : a) + ":" + (r < 10 ? "0" + r : r)
        }), setInterval(l(u.default.mark(function e() {
            var n, i, s;
            return u.default.wrap(function(e) {
                for (;;) switch (e.prev = e.next) {
                  case 0:
                    if (0 !== r) {
                        e.next = 22;
                        break;
                    }
                    if (0 !== a) {
                        e.next = 20;
                        break;
                    }
                    if (!t.data.finished) {
                        e.next = 4;
                        break;
                    }
                    return e.abrupt("return");

                  case 4:
                    if (n = wx.getStorageSync("openid"), i = null, t.data.activityId) {
                        e.next = 12;
                        break;
                    }
                    return e.next = 9, p.default.finishAnswer({
                        openid: n,
                        totalTime: 0,
                        type: 2
                    });

                  case 9:
                    i = e.sent, e.next = 15;
                    break;

                  case 12:
                    return e.next = 14, p.default.activityFinish({
                        openid: n,
                        activityId: t.data.activityId,
                        totalTime: 0,
                        type: 2
                    });

                  case 14:
                    i = e.sent;

                  case 15:
                    return t.setData({
                        finished: !0,
                        correct: i.result.correct
                    }), clearInterval(t.data.interval), wx.redirectTo({
                        url: "/answer/pages/dailyAnswerFinish/dailyAnswerFinish?correct=" + i.result.correct + "&type=1"
                    }), t.data.activityId || (s = "", i.result.rewards.forEach(function(e, t) {
                        s += 0 === t ? e.name + " +" + e.rewardAdd : "\r\n" + e.name + " +" + e.rewardAdd;
                    }), "" !== s && wx.showToast({
                        title: s,
                        icon: "none",
                        duration: 2e3
                    })), e.abrupt("return");

                  case 20:
                    a--, r = 60;

                  case 22:
                    r--, t.setData({
                        countdown: (a < 10 ? "0" + a : a) + ":" + (r < 10 ? "0" + r : r),
                        timeLimit: --t.data.timeLimit
                    });

                  case 24:
                  case "end":
                    return e.stop();
                }
            }, e);
        })), 1e3);
    },
    getQuestion: (d = l(u.default.mark(function e() {
        var t, a, r, n, i;
        return u.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                if (t = wx.getStorageSync("openid"), e.prev = 1, a = null, this.data.activityId) {
                    e.next = 9;
                    break;
                }
                return e.next = 6, p.default.questions({
                    openid: t,
                    type: 2
                });

              case 6:
                a = e.sent, e.next = 12;
                break;

              case 9:
                return e.next = 11, p.default.activityQuestions({
                    openid: t,
                    activityId: this.data.activityId,
                    type: 2
                });

              case 11:
                a = e.sent;

              case 12:
                r = [], n = JSON.parse(a.result.answer.content), Object.keys(n).forEach(function(e) {
                    n[e] && r.push({
                        letter: e,
                        spec: n[e],
                        selected: !1,
                        correct: !1,
                        error: !1
                    });
                }), i = 1 === a.result.answer.questionType ? "单选题" : 2 === a.result.answer.questionType ? "多选题" : "判断题", 
                this.setData({
                    question: a.result.answer.title,
                    questionType: a.result.answer.questionType,
                    questionTypeName: i,
                    imageArray: "" === a.result.answer.images ? [] : a.result.answer.images.split("##"),
                    options: r,
                    answer: a.result.answer.answer,
                    analysis: a.result.answer.analysis,
                    indexNum: a.result.indexNum,
                    endNum: a.result.endNum,
                    questionId: a.result.answer.id,
                    paperId: a.result.paperId
                }), 2 == a.result.answer.questionType && this.setData({
                    answerProgress: 2,
                    disable: !1
                }), e.next = 23;
                break;

              case 20:
                e.prev = 20, e.t0 = e.catch(1), console.log(e.t0);

              case 23:
              case "end":
                return e.stop();
            }
        }, e, this, [ [ 1, 20 ] ]);
    })), function() {
        return d.apply(this, arguments);
    }),
    getRewardCards: function() {
        var e = this;
        return l(u.default.mark(function t() {
            var a, r, n, i;
            return u.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    return a = wx.getStorageSync("openid"), t.prev = 1, t.next = 4, p.default.rewardList({
                        openid: a
                    });

                  case 4:
                    r = t.sent, n = r.result.list, i = e.data.list, Object.keys(i).forEach(function(e) {
                        n.forEach(function(t) {
                            i[e].cardname === t.name && (i[e].cardId = t.id, i[e].cardNum = t.rewardCount);
                        });
                    }), e.setData({
                        list: i
                    }), t.next = 14;
                    break;

                  case 11:
                    t.prev = 11, t.t0 = t.catch(1), console.log(t.t0.msg);

                  case 14:
                  case "end":
                    return t.stop();
                }
            }, t, null, [ [ 1, 11 ] ]);
        }))();
    },
    onLoad: (s = l(u.default.mark(function e(t) {
        var a;
        return u.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                return this.setData({
                    timeLimit: t.limit ? t.limit : h.globalData.dailyTimeLimit,
                    activityId: t.id
                }), this.getQuestion(), e.next = 4, this.getRewardCards();

              case 4:
                this.data.list.double.cardNum > 0 && !this.data.activityId ? this.setData({
                    dialogShow: !0
                }) : (a = this.changeCountDown(this.data.timeLimit), this.setData({
                    interval: a
                })), this.commitMultipleChoiceDebounce = this.debounce(this.commitMultipleChoice, 500, !1), 
                this.multipleCompleteDebounce = this.debounce(this.multipleComplete, 500, !1), this.nonMultipleCompleteDebounce = this.debounce(this.nonMultipleComplete, 500, !1), 
                this.handleCardDebounce = this.debounce(this.handleCard, 500, !1);

              case 9:
              case "end":
                return e.stop();
            }
        }, e, this);
    })), function(e) {
        return s.apply(this, arguments);
    }),
    onShow: function() {
        this.data.finished && (clearInterval(this.data.interval), wx.redirectTo({
            url: "/answer/pages/dailyAnswerFinish/dailyAnswerFinish?correct=" + this.data.correct + "&type=1"
        }));
    },
    onHide: (i = l(u.default.mark(function e() {
        var t, a;
        return u.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                if (!this.data.finished) {
                    e.next = 2;
                    break;
                }
                return e.abrupt("return");

              case 2:
                if (this.data.started) {
                    e.next = 6;
                    break;
                }
                return clearInterval(this.data.interval), wx.switchTab({
                    url: "/pages/answer/answer"
                }), e.abrupt("return");

              case 6:
                if (t = wx.getStorageSync("openid"), a = null, this.data.activityId) {
                    e.next = 14;
                    break;
                }
                return e.next = 11, p.default.finishAnswer({
                    openid: t,
                    totalTime: 0,
                    type: 2
                });

              case 11:
                a = e.sent, e.next = 17;
                break;

              case 14:
                return e.next = 16, p.default.activityFinish({
                    openid: t,
                    activityId: this.data.activityId,
                    totalTime: 0,
                    type: 2
                });

              case 16:
                a = e.sent;

              case 17:
                this.setData({
                    finished: !0,
                    correct: a.result.correct
                }), clearInterval(this.data.interval);

              case 19:
              case "end":
                return e.stop();
            }
        }, e, this);
    })), function() {
        return i.apply(this, arguments);
    }),
    onUnload: (n = l(u.default.mark(function e() {
        var t, a;
        return u.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                if (!this.data.finished) {
                    e.next = 2;
                    break;
                }
                return e.abrupt("return");

              case 2:
                if (this.data.started) {
                    e.next = 6;
                    break;
                }
                return clearInterval(this.data.interval), wx.switchTab({
                    url: "/pages/answer/answer"
                }), e.abrupt("return");

              case 6:
                if (t = wx.getStorageSync("openid"), a = null, this.data.activityId) {
                    e.next = 14;
                    break;
                }
                return e.next = 11, p.default.finishAnswer({
                    openid: t,
                    totalTime: 0,
                    type: 2
                });

              case 11:
                a = e.sent, e.next = 17;
                break;

              case 14:
                return e.next = 16, p.default.activityFinish({
                    openid: t,
                    activityId: this.data.activityId,
                    totalTime: 0,
                    type: 2
                });

              case 16:
                a = e.sent;

              case 17:
                this.setData({
                    finished: !0,
                    correct: a.result.correct
                }), clearInterval(this.data.interval);

              case 19:
              case "end":
                return e.stop();
            }
        }, e, this);
    })), function() {
        return n.apply(this, arguments);
    }),
    nonMultipleChoice: (r = l(u.default.mark(function e(t) {
        var a;
        return u.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                if (a = wx.getStorageSync("openid"), !this.data.disable) {
                    e.next = 3;
                    break;
                }
                return e.abrupt("return");

              case 3:
                if (e.prev = 3, this.data.activityId) {
                    e.next = 9;
                    break;
                }
                return e.next = 7, p.default.commitAnswer({
                    openid: a,
                    answer: t.currentTarget.dataset.answer,
                    answerId: this.data.questionId,
                    type: 2,
                    endNum: this.data.endNum,
                    indexNum: this.data.indexNum,
                    paperId: this.data.paperId
                });

              case 7:
                e.next = 11;
                break;

              case 9:
                return e.next = 11, p.default.activityCommit({
                    openid: a,
                    activityId: this.data.activityId,
                    answer: t.currentTarget.dataset.answer,
                    answerId: this.data.questionId,
                    type: 2,
                    endNum: this.data.endNum,
                    indexNum: this.data.indexNum,
                    paperId: this.data.paperId
                });

              case 11:
                t.currentTarget.dataset.answer == this.data.answer ? this.setData({
                    answerState: 1,
                    disable: !0,
                    correctIndex: t.currentTarget.dataset.index,
                    started: !0
                }) : this.setData({
                    answerState: 2,
                    disable: !0,
                    correctIndex: this.data.answer.charCodeAt(0) - "A".charCodeAt(),
                    errorIndex: t.currentTarget.dataset.index,
                    started: !0
                }), this.data.indexNum === this.data.endNum && this.setData({
                    answerProgress: 3
                }), e.next = 19;
                break;

              case 15:
                e.prev = 15, e.t0 = e.catch(3), console.log(e.t0), wx.showToast({
                    title: "网络异常",
                    icon: "none",
                    duration: 1e3
                });

              case 19:
              case "end":
                return e.stop();
            }
        }, e, this, [ [ 3, 15 ] ]);
    })), function(e) {
        return r.apply(this, arguments);
    }),
    multipleChoice: function(e) {
        var t = "options[" + e.currentTarget.dataset.index + "].selected";
        this.data.options[e.currentTarget.dataset.index].selected ? this.setData(o({}, t, !1)) : this.setData(o({}, t, !0));
    },
    commitMultipleChoice: (a = l(u.default.mark(function e(t) {
        var a, r, n, i, s, d, c, l;
        return u.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                for (a = wx.getStorageSync("openid"), r = 0, n = 0; n < this.data.options.length; n++) this.data.options[n].selected && r++;
                if (0 !== r) {
                    e.next = 6;
                    break;
                }
                return wx.showToast({
                    title: "尚未选择答案",
                    icon: "none",
                    duration: 1e3
                }), e.abrupt("return");

              case 6:
                for (i = "", n = 0; n < this.data.options.length; n++) s = this.data.options[n].selected, 
                d = this.data.options[n].letter, s && (i += d);
                if (e.prev = 8, this.data.activityId) {
                    e.next = 14;
                    break;
                }
                return e.next = 12, p.default.commitAnswer({
                    openid: a,
                    answer: i,
                    answerId: this.data.questionId,
                    type: 2,
                    endNum: this.data.endNum,
                    indexNum: this.data.indexNum,
                    paperId: this.data.paperId
                });

              case 12:
                e.next = 16;
                break;

              case 14:
                return e.next = 16, p.default.activityCommit({
                    openid: a,
                    activityId: this.data.activityId,
                    answer: i,
                    answerId: this.data.questionId,
                    type: 2,
                    endNum: this.data.endNum,
                    indexNum: this.data.indexNum,
                    paperId: this.data.paperId
                });

              case 16:
                for (n = 0; n < this.data.options.length; n++) s = this.data.options[n].selected, 
                d = this.data.options[n].letter, this.data.answer.includes(d) ? (c = "options[" + n + "].correct", 
                this.setData(o({}, c, !0))) : this.data.answer.includes(d) && (l = "options[" + n + "].error", 
                this.setData(o({}, l, !0)));
                if (this.data.indexNum !== this.data.endNum) {
                    e.next = 22;
                    break;
                }
                return this.setData({
                    answerState: i === this.data.answer ? 1 : 2,
                    disable: !0,
                    answerProgress: 3,
                    started: !0
                }), e.abrupt("return");

              case 22:
                this.setData({
                    answerState: i === this.data.answer ? 1 : 2,
                    disable: !0,
                    answerProgress: 1,
                    started: !0
                });

              case 23:
                e.next = 29;
                break;

              case 25:
                e.prev = 25, e.t0 = e.catch(8), console.log(e.t0), wx.showToast({
                    title: "网络异常",
                    icon: "none",
                    duration: 1e3
                });

              case 29:
              case "end":
                return e.stop();
            }
        }, e, this, [ [ 8, 25 ] ]);
    })), function(e) {
        return a.apply(this, arguments);
    }),
    nextQuestion: function() {
        this.data.disable ? (this.setData({
            answerState: 0,
            correctIndex: -1,
            errorIndex: -1,
            disable: !1
        }), this.getQuestion()) : wx.showToast({
            title: "尚未选择答案",
            icon: "none",
            duration: 1e3
        });
    },
    nonMultipleComplete: (t = l(u.default.mark(function e() {
        var t, a, r;
        return u.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                if (!this.data.disable) {
                    e.next = 18;
                    break;
                }
                if (t = wx.getStorageSync("openid"), a = null, this.data.activityId) {
                    e.next = 9;
                    break;
                }
                return e.next = 6, p.default.finishAnswer({
                    openid: t,
                    totalTime: 0,
                    type: 2
                });

              case 6:
                a = e.sent, e.next = 12;
                break;

              case 9:
                return e.next = 11, p.default.activityFinish({
                    openid: t,
                    activityId: this.data.activityId,
                    totalTime: 0,
                    type: 2
                });

              case 11:
                a = e.sent;

              case 12:
                this.setData({
                    finished: !0
                }), clearInterval(this.data.interval), wx.redirectTo({
                    url: "/answer/pages/dailyAnswerFinish/dailyAnswerFinish?correct=" + a.result.correct + "&type=1"
                }), this.data.activityId || (r = "", a.result.rewards.forEach(function(e, t) {
                    r += 0 === t ? e.name + " +" + e.rewardAdd : "\r\n" + e.name + " +" + e.rewardAdd;
                }), "" !== r && wx.showToast({
                    title: r,
                    icon: "none",
                    duration: 2e3
                })), e.next = 19;
                break;

              case 18:
                wx.showToast({
                    title: "尚未选择答案",
                    icon: "none",
                    duration: 1e3
                });

              case 19:
              case "end":
                return e.stop();
            }
        }, e, this);
    })), function() {
        return t.apply(this, arguments);
    }),
    multipleComplete: (e = l(u.default.mark(function e() {
        var t, a, r;
        return u.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                if (t = wx.getStorageSync("openid"), a = null, this.data.activityId) {
                    e.next = 8;
                    break;
                }
                return e.next = 5, p.default.finishAnswer({
                    openid: t,
                    totalTime: 0,
                    type: 2
                });

              case 5:
                a = e.sent, e.next = 11;
                break;

              case 8:
                return e.next = 10, p.default.activityFinish({
                    openid: t,
                    activityId: this.data.activityId,
                    totalTime: 0,
                    type: 2
                });

              case 10:
                a = e.sent;

              case 11:
                this.setData({
                    finished: !0
                }), clearInterval(this.data.interval), wx.redirectTo({
                    url: "/answer/pages/dailyAnswerFinish/dailyAnswerFinish?correct=" + a.result.correct + "&type=1"
                }), this.data.activityId || (r = "", a.result.rewards.forEach(function(e, t) {
                    r += 0 === t ? e.name + " +" + e.rewardAdd : "\r\n" + e.name + " +" + e.rewardAdd;
                }), "" !== r && wx.showToast({
                    title: r,
                    icon: "none",
                    duration: 2e3
                }));

              case 15:
              case "end":
                return e.stop();
            }
        }, e, this);
    })), function() {
        return e.apply(this, arguments);
    }),
    open: function() {
        this.setData({
            show: !0
        });
    },
    buttontap: function(e) {
        console.log(e.detail);
    },
    chooseCard: function(e) {
        var t = e.currentTarget.dataset.card;
        this.data.list[t].cardNum && this.setData({
            cardActive: t
        });
    },
    handleCard: function() {
        var e = this;
        return l(u.default.mark(function t() {
            var a, r, n, i, s, d, c, l, h, w, f, m, x, y, v, I;
            return u.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    if (a = e.data.cardActive || "") {
                        t.next = 4;
                        break;
                    }
                    return e.setData({
                        cardActive: "",
                        show: !1
                    }), t.abrupt("return");

                  case 4:
                    return r = wx.getStorageSync("openid"), t.next = 7, p.default.useCard({
                        openid: r,
                        answerId: e.data.questionId,
                        rewardId: e.data.list[a].cardId,
                        rewardCount: e.data.list[a].cardNum
                    });

                  case 7:
                    if (t.prev = 7, "resurrection" !== a) {
                        t.next = 36;
                        break;
                    }
                    if (e.data.disable) {
                        t.next = 12;
                        break;
                    }
                    return wx.showToast({
                        title: "不能使用复活卡",
                        icon: "none",
                        duration: 1e3
                    }), t.abrupt("return");

                  case 12:
                    if (e.data.indexNum === e.data.endNum) {
                        t.next = 17;
                        break;
                    }
                    e.setData({
                        answerState: 0,
                        correctIndex: -1,
                        errorIndex: -1,
                        disable: !1
                    }), e.getQuestion(), t.next = 34;
                    break;

                  case 17:
                    if (i = wx.getStorageSync("openid"), s = null, e.data.activityId) {
                        t.next = 25;
                        break;
                    }
                    return t.next = 22, p.default.finishAnswer({
                        openid: i,
                        totalTime: 0,
                        type: 2
                    });

                  case 22:
                    s = t.sent, t.next = 28;
                    break;

                  case 25:
                    return t.next = 27, p.default.activityFinish({
                        openid: i,
                        activityId: e.data.activityId,
                        totalTime: 0,
                        type: 2
                    });

                  case 27:
                    s = t.sent;

                  case 28:
                    e.setData({
                        finished: !0
                    }), clearInterval(e.data.interval), wx.redirectTo({
                        url: "/answer/pages/dailyAnswerFinish/dailyAnswerFinish?correct=" + s.result.correct + "&type=1"
                    }), d = "", s.result.rewards.forEach(function(e, t) {
                        d += 0 === t ? e.name + " +" + e.rewardAdd : "\r\n" + e.name + " +" + e.rewardAdd;
                    }), "" !== d && wx.showToast({
                        title: d,
                        icon: "none",
                        duration: 2e3
                    });

                  case 34:
                    t.next = 92;
                    break;

                  case 36:
                    if ("skip" !== a) {
                        t.next = 91;
                        break;
                    }
                    if (!e.data.disable) {
                        t.next = 40;
                        break;
                    }
                    return wx.showToast({
                        title: "不能使用跳过卡",
                        icon: "none",
                        duration: 1e3
                    }), t.abrupt("return");

                  case 40:
                    if (e.data.indexNum === e.data.endNum) {
                        t.next = 59;
                        break;
                    }
                    if (t.prev = 41, c = wx.getStorageSync("openid"), e.data.activityId) {
                        t.next = 48;
                        break;
                    }
                    return t.next = 46, p.default.commitAnswer({
                        openid: c,
                        answer: e.data.answer,
                        answerId: e.data.questionId,
                        type: 2,
                        endNum: e.data.endNum,
                        indexNum: e.data.indexNum,
                        paperId: e.data.paperId
                    });

                  case 46:
                    t.next = 50;
                    break;

                  case 48:
                    return t.next = 50, p.default.activityCommit({
                        openid: c,
                        activityId: e.data.activityId,
                        answer: e.data.answer,
                        answerId: e.data.questionId,
                        type: 2,
                        endNum: e.data.endNum,
                        indexNum: e.data.indexNum,
                        paperId: e.data.paperId
                    });

                  case 50:
                    t.next = 55;
                    break;

                  case 52:
                    t.prev = 52, t.t0 = t.catch(41), console.log(t.t0);

                  case 55:
                    e.setData({
                        answerState: 0,
                        correctIndex: -1,
                        errorIndex: -1,
                        disable: !1,
                        started: !0
                    }), e.getQuestion(), t.next = 89;
                    break;

                  case 59:
                    if (t.prev = 59, l = wx.getStorageSync("openid"), e.data.activityId) {
                        t.next = 66;
                        break;
                    }
                    return t.next = 64, p.default.commitAnswer({
                        openid: l,
                        answer: e.data.answer,
                        answerId: e.data.questionId,
                        type: 2,
                        endNum: e.data.endNum,
                        indexNum: e.data.indexNum,
                        paperId: e.data.paperId
                    });

                  case 64:
                    t.next = 68;
                    break;

                  case 66:
                    return t.next = 68, p.default.activityCommit({
                        openid: l,
                        activityId: e.data.activityId,
                        answer: e.data.answer,
                        answerId: e.data.questionId,
                        type: 2,
                        endNum: e.data.endNum,
                        indexNum: e.data.indexNum,
                        paperId: e.data.paperId
                    });

                  case 68:
                    if (h = null, e.data.activityId) {
                        t.next = 75;
                        break;
                    }
                    return t.next = 72, p.default.finishAnswer({
                        openid: l,
                        totalTime: 0,
                        type: 2
                    });

                  case 72:
                    h = t.sent, t.next = 78;
                    break;

                  case 75:
                    return t.next = 77, p.default.activityFinish({
                        openid: l,
                        activityId: e.data.activityId,
                        totalTime: 0,
                        type: 2
                    });

                  case 77:
                    h = t.sent;

                  case 78:
                    e.setData({
                        finished: !0
                    }), clearInterval(e.data.interval), wx.redirectTo({
                        url: "/answer/pages/dailyAnswerFinish/dailyAnswerFinish?correct=" + h.result.correct + "&type=1"
                    }), w = "", h.result.rewards.forEach(function(e, t) {
                        w += 0 === t ? e.name + " +" + e.rewardAdd : "\r\n" + e.name + " +" + e.rewardAdd;
                    }), "" !== w && wx.showToast({
                        title: w,
                        icon: "none",
                        duration: 2e3
                    }), t.next = 89;
                    break;

                  case 86:
                    t.prev = 86, t.t1 = t.catch(59), console.log(t.t1);

                  case 89:
                    t.next = 92;
                    break;

                  case 91:
                    "delay" === a ? (clearInterval(e.data.interval), f = e.data.timeLimit + 30, m = e.changeCountDown(f), 
                    e.setData({
                        timeLimit: f,
                        interval: m
                    })) : "debug" === a && (x = e.data.options, y = -1, e.data.options.forEach(function(t, a) {
                        -1 === e.data.answer.indexOf(t.letter) && (y = a);
                    }), -1 !== y && x.splice(y, 1), e.setData({
                        options: x
                    }));

                  case 92:
                    return t.next = 94, p.default.rewardCount({
                        openid: r,
                        rewardId: e.data.list[a].cardId
                    });

                  case 94:
                    v = t.sent, I = "list." + a + ".cardNum", e.setData((o(n = {}, I, v.result), o(n, "cardActive", ""), 
                    o(n, "show", !1), n)), t.next = 102;
                    break;

                  case 99:
                    t.prev = 99, t.t2 = t.catch(7), console.log(t.t2);

                  case 102:
                  case "end":
                    return t.stop();
                }
            }, t, null, [ [ 7, 99 ], [ 41, 52 ], [ 59, 86 ] ]);
        }))();
    },
    dialogHide: function() {
        var e = this.changeCountDown(this.data.timeLimit);
        this.setData({
            interval: e,
            dialogShow: !1
        });
    },
    useCard: function(e) {
        var t = this;
        return l(u.default.mark(function a() {
            var r, n, i;
            return u.default.wrap(function(a) {
                for (;;) switch (a.prev = a.next) {
                  case 0:
                    return r = e.currentTarget.dataset.card, n = wx.getStorageSync("openid"), a.prev = 2, 
                    a.next = 5, p.default.useCard({
                        openid: n,
                        rewardId: t.data.list[r].cardId,
                        rewardCount: t.data.list[r].cardNum
                    });

                  case 5:
                    a.sent, p.default.rewardCount({
                        openid: n,
                        rewardId: t.data.list[r].cardId
                    }), i = t.changeCountDown(t.data.timeLimit), t.setData({
                        dialogShow: !1,
                        interval: i
                    }), a.next = 14;
                    break;

                  case 11:
                    a.prev = 11, a.t0 = a.catch(2), console.log(a.t0);

                  case 14:
                  case "end":
                    return a.stop();
                }
            }, a, null, [ [ 2, 11 ] ]);
        }))();
    }
});